<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
	<meta charset="utf-8" />
		<title>销售人员</title>
<!-- 		<meta name="description" content="" /> -->
<!-- 		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> -->
		
<!-- 		<script type="text/javascript" src="plugins/ext/ext-base.js"></script> -->
<!-- 		<script type="text/javascript"src="plugins/ext/ext-all.js"></script> -->
<!-- 		<script type="text/javascript"src="plugins/ext/ext-lang-zh_CN.js"></script> -->
<!-- 		<link rel="stylesheet" href="plugins/ext/resources/css/ext-all.css" /> -->
<!-- 		<script type="text/javascript"src="plugins/ext4/ext-all-debug.js"></script> -->
		
<!-- 			<script type="text/javascript" src="static/js/jquery-1.7.2.js" /> -->
		
					<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="static/js/jquery-1.7.2.js" />
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/locale/ext-lang-zh_CN.js"></script>
			<link rel="stylesheet" href="plugins/websocketInstantMsg/ext4/resources/css/ext-all.css" />
			
</head>

<body class="no-skin">
		
	<div class="main-container" id="main-container"style="overflow-x:scroll">
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<div id="gsmLacciDayList"></div>
							<div id="contractInfo"style="width: 50%;height: 50%;"></div>
							<div id="invoice_title" style="width: 100%;height: 100%;"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
/**>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>实体信息js<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  
 
Ext.namespace('monitorAnalyzeReport');
var monitorAnalyzeReport;
Ext.onReady(function() {
	Ext.QuickTips.init();

// 	var sm = Ext.grid.RowSelectionModel;
// 	sm: new Ext.grid.RowSelectionModel({
// 	singleSelect: true
// 	}),
	var sm = Ext.create('Ext.selection.CheckboxModel',{checkOnly:false});
	var cm = [

  new Ext.grid.RowNumberer({
		  header : "序号",
		  width :50,
  }
  ), 
   	{
   		header : "ID",
   		tooltip : "ID",
   		width : 140,
   		sortable : true,
   		align:"left",
   		hidden: true,
   		dataIndex : 'ID'
   	},
	{
   		header : "实体编码",
   		tooltip : "实体编码",
   		width : 140,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ENTITIES_CODE'
   	},{
   		header : "总体编码",
   		tooltip : "总体编码",
   		width : 120,
   		align:"left",
   		sortable : true,
   		dataIndex : 'OVERALL_CODE'
   	},
   	{
   		header : "社会统一信用代码",
   		tooltip : "社会统一信用代码",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'SOCIAL_CREDIT_CODE'
   		
   	},{
   		header : "实体全称",
   		tooltip : "实体全称",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ENTITIES_FULLNAME'
   		
   	},
   	{
   		header : "实体英文名称",
   		tooltip : "实体英文名称",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ENTITY_EN_NAME'
   		
   	},
   	{
   		header : "实体简称",
   		tooltip : "实体简称",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ENTITY_ABBREVIATED'
   		
   	},{
   		header : "实体类型",
   		tooltip : "实体类型",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ENTITIES_CLASS'
   		
   	},
   	{
   		header : "客户",
   		tooltip : "客户",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'GUEST'
   		
   	},
   	{
   		header : "承运人",
   		tooltip : "承运人",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'FREIGHTER'
   		
   	},
   	{
   		header : "供应商",
   		tooltip : "供应商",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'SUPPLIER'
   		
   	},{
   		header : "内部分公司",
   		tooltip : "内部分公司",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'INTERNAL_BRANCH'
   		
   	},{
   		header : "实体来源",
   		tooltip : "实体来源",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ENTITY_SOURCE'
   		
   	},{
   		header : "业务类别",
   		tooltip : "业务类别",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'BUSINESS_CLASS_ID'
   		
   	},{
   		header : "财务联系人",
   		tooltip : "财务联系人",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'FINANCIAL_CONTACT'
   		
   	},{
   		header : "财务联系电话",
   		tooltip : "财务联系电话",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'FINANCIAL_CONTACT_PHONE'
   		
   	}
   	,{
   		header : "业务联系人",
   		tooltip : "业务联系人",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'BUSINESS_CLASS_ID'
   		
   	}
   	,{
   		header : "业务联系电话",
   		tooltip : "业务联系电话",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'BUSINESS_CLASS_ID'
   		
   	}
   	,{
   		header : "开户行账号",
   		tooltip : "开户行账号",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'BANK_ACCOUNT'
   		
   	}
   	,{
   		header : "结算类别",
   		tooltip : "结算类别",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'SETTLEMENT_CATEGORY_ID'
   		
   	}
   	,{
   		header : "邮箱",
   		tooltip : "邮箱",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'EMAIL'
   		
   	}
   	,{
   		header : "是否可用",
   		tooltip : "是否可用",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ENABLED'
   		
   	}
   	,{
   		header : "收付类型",
   		tooltip : "收付类型",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'RECEIPTS_PAYMENT_TYPE'
   		
   	}
   	,{
   		header : "应收金额",
   		tooltip : "应收金额",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'AMOUNT_RECEIVABLE'
   		
   	}
   	,{
   		header : "应收期限",
   		tooltip : "应收期限",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'ACCOUNTS_RECEIVABLE_PERIOD'
   		
   	}
   	,{
   		header : "应付金额",
   		tooltip : "应付金额",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'AMOUNT_PAYABLE'
   		
   	}
   	,{
   		header : "应付期限",
   		tooltip : "应付期限",
   		width : 80,
   		sortable : true,
   		align:"left",
   		dataIndex : 'COPE_DEALLINE'
   		
   	}
   	
   	
   	];
// 	var btnsubmit = new Ext.Button({
// 		                  text: '提交',
// 		                  handler: btnsubmitclick
// 		              });
// 	var btnsubmitclick = function () {
// 		                  Ext.MessageBox.alert('提示', '你点了确定按钮!');
// 		              }

//    	var reader = new Ext.data.JsonReader({
//    		root : 'root',
//    		totalProperty : 'total'
//    	}, [{
//    		name:'ID'
//    	},  {
//    	    name: 'ENTITIES_CODE'
//    	},{
//    	    name : 'OVERALL_CODE'
//    	},{
//    	    name : 'SOCIAL_CREDIT_CODE'
//    	}
//    	,{
//    	    name : 'ENTITIES_FULLNAME'
//    	}
//    	,{
//    	    name : 'ENTITY_EN_NAME'
//    	}
//    	,{
//    	    name : 'ENTITY_ABBREVIATED'
//    	}
//    	,{
//    	    name : 'ENTITIES_CLASS'
//    	}
//    	,{
//    	    name : 'GUEST'
//    	}
//    	,{
//    	    name : 'CARRIER'
//    	}
//    	,{
//    	    name : 'SUPPLIER'
//    	}
//    	,{
//    	    name : 'INTERNAL_BRANCH'
//    	}
//    	,{
//    	    name : 'ENTITY_SOURCE'
//    	}
//    	,{
//    	    name : 'BUSINESS_CLASS_ID'
//    	}
//    	,{
//    	    name : 'FINANCIAL_CONTACT'
//    	}
//    	,{
//    	    name : 'FINANCIAL_CONTACT_PHONE'
//    	}
//    	,{
//    	    name : 'BUSINESS_CLASS_ID'
//    	}
//    	,{
//    	    name : 'BUSINESS_CLASS_ID'
//    	}
//    	,{
//    	    name : 'BANK_ACCOUNT'
//    	}
//    	,{
//    	    name : 'SETTLEMENT_CATEGORY_ID'
//    	}
//    	,{
//    	    name : 'EMAIL'
//    	}
//    	,{
//    	    name : 'ENABLE'
//    	}
//    	,{
//    	    name : 'RECEIPTS_PAYMENT_TYPE'
//    	}
//    	,{
//    	    name : 'AMOUNT_RECEIVABLE'
//    	}
//    	,{
//    	    name : 'ACCOUNTS_RECEIVABLE_PERIOD'
//    	}
//    	,{
//    	    name : 'AMOUNT_PAYABLE'
//    	}
//    	,{
//    	    name : 'COPE_DEALLINE'
//    	}
//    	]);
   	Ext.define('store', {
		extend : 'Ext.data.Model',
		fields :[{
	   		name:'ID'
	   	},  {
	   	    name: 'ENTITIES_CODE'
	   	},{
	   	    name : 'OVERALL_CODE'
	   	},{
	   	    name : 'SOCIAL_CREDIT_CODE'
	   	}
	   	,{
	   	    name : 'ENTITIES_FULLNAME'
	   	}
	   	,{
	   	    name : 'ENTITY_EN_NAME'
	   	}
	   	,{
	   	    name : 'ENTITY_ABBREVIATED'
	   	}
	   	,{
	   	    name : 'ENTITIES_CLASS'
	   	}
	   	,{
	   	    name : 'GUEST'
	   	}
	   	,{
	   	    name : 'FREIGHTER'
	   	}
	   	,{
	   	    name : 'SUPPLIER'
	   	}
	   	,{
	   	    name : 'INTERNAL_BRANCH'
	   	}
	   	,{
	   	    name : 'ENTITY_SOURCE'
	   	}
	   	,{
	   	    name : 'BUSINESS_CLASS_ID'
	   	}
	   	,{
	   	    name : 'FINANCIAL_CONTACT'
	   	}
	   	,{
	   	    name : 'FINANCIAL_CONTACT_PHONE'
	   	}
	   	,{
	   	    name : 'BUSINESS_CLASS_ID'
	   	}
	   	,{
	   	    name : 'BUSINESS_CLASS_ID'
	   	}
	   	,{
	   	    name : 'BANK_ACCOUNT'
	   	}
	   	,{
	   	    name : 'SETTLEMENT_CATEGORY_ID'
	   	}
	   	,{
	   	    name : 'EMAIL'
	   	}
	   	,{
	   	    name : 'ENABLE'
	   	}
	   	,{
	   	    name : 'RECEIPTS_PAYMENT_TYPE'
	   	}
	   	,{
	   	    name : 'AMOUNT_RECEIVABLE'
	   	}
	   	,{
	   	    name : 'ACCOUNTS_RECEIVABLE_PERIOD'
	   	}
	   	,{
	   	    name : 'AMOUNT_PAYABLE'
	   	}
	   	,{
	   	    name : 'COPE_DEALLINE'
	   	}
	   	]
	});
//    	var store =  new Ext.data.Store({
<%--    	 		url: '<%=basePath%>entityMaintain/test',			 --%>
//    			reader : reader
//    	})
	  var store = Ext.create('Ext.data.Store', {
			model : 'store',
			pageSize:10,

//			pageSize : thePageSize,
			id:'store',
			proxy : {
				type : 'ajax',
				/* actionMethods : {
					read : 'POST'
				}, *///将提交方式改为post
				url: '<%=basePath%>entityMaintain/test',
				reader : {
					type : 'json',
					root : 'result.list',
					totalProperty:'result.total'
				}
			}
	 
		});

	var queding = Ext.create("Ext.Button", {
     	text: '确定',
     	handler:function(){
     		winPanel.close();
//      		var records = Ext.getCmp('tree').getSelectionModel().getSelections();
 		}
  }
   	
  );
	var root = Ext.create('Ext.data.TreeStore', {
//		expanded: true,
		text:"",
		id:'root',
		children: [ 
		           		{ text:"客户",checked:false,expanded: true,children: [{ text:"直客",leaf:true,checked:false},{ text:"同行",leaf:true,checked:false}]},
		           		{ text:"承运人",checked:false,expanded: true,children: [{ text:"船公司",leaf:true,checked:false},{ text:"航空公司",leaf:true,checked:false}]},
		           		{ text:"供应商",checked:false,expanded: true,children: [{ text:"订舱单位",leaf:true,checked:false},{ text:"报关行",leaf:true,checked:false},{ text:"场站",leaf:true,checked:false},{ text:"仓库",leaf:true,checked:false},{ text:"车队",leaf:true,checked:false},{ text:"其他",leaf:true,checked:false}]},
		           		{ text:"内部分公司",checked:false,leaf:true}
		          ]
	});
	function addUser(node,pnode) {
    	var customerType="";
    	var transport_type = "";
    	var provider_type = "";
    	var inner_branch = "";
    	
    	var pnodeName = '';
     	var records=Ext.getCmp('tree').getChecked();
     	Ext.each(records, function(item){
     		
     		if(item.getDepth()==2 && item.parentNode!=null && item.get("checked")){
     			//alert(item.parentNode.data.text);
     			var parentNodeText=item.parentNode.data.text;
     			alert(parentNodeText);
     			if(parentNodeText=='客户'){
     				customerType += ','+item.data.text;
     			}else if(parentNodeText=='承运人'){
     				transport_type += ','+item.data.text;
     			}else if(parentNodeText=='供应商'){
     				provider_type += ','+item.data.text;
     			}
     		}else if(item.getDepth()==1 && item.get("checked")){
     			pnodeName += ','+item.data.text;
     		}         		
     	}); 
     	if(!Ext.isEmpty(customerType)) customerType = customerType.substr(1);
     	if(!Ext.isEmpty(transport_type)) transport_type = transport_type.substr(1);
     	if(!Ext.isEmpty(provider_type)) provider_type = provider_type.substr(1);
     	pnodeName=pnodeName.substr(1);
     	Ext.getCmp('myform').getForm().findField('ENTITIES_CLASS').setValue(pnodeName);       
     	Ext.getCmp('myform').getForm().findField('GUEST').setValue(customerType);
     	Ext.getCmp('myform').getForm().findField('FREIGHTER').setValue(transport_type);
     	Ext.getCmp('myform').getForm().findField('SUPPLIER').setValue(provider_type);
	}
	 var treelocal = new Ext.tree.TreePanel({
		 	id:"tree",
		 	border: false,  //边框
			renderTo: Ext.getBody(),
			rootVisible: false,  //隐藏根节点
			useArrows:false, //树 ,
			autoScroll: false,
			singleExpand:false,   //展示单个子节点，其它的子节点合并。
			title:'实体类型层级关系树形结构', 
// 			loader:new Ext.tree.TreeLoader(),
          	root:root,
          	listeners:{
				'checkchange':function(node, checked) {
					//获得父节点
					pNode = node.parentNode;
					//改变当前节点的选中状态
					node.checked = checked;
					//判断当前节点是否为叶子节点
					var isLeaf = node.isLeaf();
					//当该节点有子节点时,将所有子节点的选中状态同化
					if (!isLeaf){
						//cascade是指从当前节点node开始逐层下报，即遍历当前节点的每一个节点(无论有多少层级结构,详参API)
						node.cascade(function(node){
							for(var i=0;i<node.length;i++){
// 								node.attributes.children[i].checked=true
								node.set("checked", checked);
							}
							
						});
					}
					//如果当前节点是选中状态
					if (checked == true) {
						//将当前节点的所有未选中的父节点选中
						for (;pNode != null && !pNode.get("checked");pNode = pNode.parentNode) {
							pNode.set("checked", true);
// 							pNode.attributes.checked=true
						}
					}else{
						//取消当前节点的所有不包含选中的子节点的父节点的选中状态
						for (;pNode != null;pNode = pNode.parentNode) {	
							//如果当前的父节点包含选中的子节点，则终止搜索过程
							if(hasCheckedNode(pNode)){
								break;
							}else{
								//否则取消当前父节点的选中状态
								pNode.set("checked", false);
							}
						}
					}
					//添加勾选的人员到人员列表去
					addUser(node,pNode);
				} 
			}

          });
	var formPanel = new Ext.form.FormPanel({
        frame: true,
        title: '表单标题',
        style: 'margin:10px',
        items: [treelocal],

    });

	var winPanel = Ext.create("Ext.window.Window", {
        title: '实体类型选择',
        width: 300,
        height: 350,
       resizable: true,
        modal: true,
       closable: true,
       maximizable: true,
       minimizable: true,
       items:[treelocal,queding]
    });


var tbtn = Ext.create("Ext.Button", {
                 	text: '新增实体',
                 	listeners: {
                     'click': function () {
//                          var row = monitorAnalyze.getSelectionModel().getSelections();
//                         for (var i = 0; i < row.length; i++) {
//                             alert(row[i].get('id'));
//                          }
//                    	 win.show();
//                     	 form.show();
						 addEntities();
                    }
                 }
              }
              );
var tbtn2 = Ext.create("Ext.Button", {
 	text: '删除实体',
 	handler: function(){
 		var records = monitorAnalyze.getSelectionModel().getSelection();
 		alert(records);
 		if(records.length==0){
 				Ext.Msg.alert("提示","请选中需要删除的实体记录");return;
 			}
 			var arr = [];
 			Ext.each(records,function(item){
 				obj = {
 						id:item.data.ID
 						
 				};
 				arr.push(obj);
 				
 			});
 			var array = JSON.stringify(arr);
 			Ext.Ajax.request({
 						url: '<%=basePath%>entityMaintain/deleteEntityMaintain',
						params:{
// 							records:Ext.JSON.encode(arr)
							array:array
								
						},
						timeout:5000,
						success:function(response){
							 Ext.MessageBox.alert("删除","删除成功");
							 var grid = Ext.getCmp('monitorAnalyze');
							 grid.store.reload();
						},
						
					});
 	}
}
);

var tbtn4 = Ext.create("Ext.Button", {
 	text: '精确查询',
 	
 	handler: function(){
		toFind();
}
});



	function toFind(){

		var formFind = Ext.create('Ext.form.Panel', {
			id:'formFind',
			frame: true,

			items: [{
				layout : 'column',
				items : [
					{
						columnWidth:0,
						layout: 'form',
						items: [{
							id:'ID',
							hidden:true,
							hideLabel:true,
							xtype:'textfield',
							fieldLabel: 'ID',
							name: 'ID'
						}]
					},{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'entityCode1',
							xtype:'textfield',
							fieldLabel: '实体编码',
							name: 'CONTRACT_NUM'
						}]
					},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'overallCode',
							xtype: 'textfield',
							fieldLabel: '总部编码',
							name: 'BUSINESS_CLASS'
						}]
					},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'entityName',
							xtype:'textfield',
							fieldLabel: '实体名称',
							name: 'REGISTRATION_DATE',
							width:150
						}
						]
					}]

			},{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id:'entityFullName',
						xtype:'textfield',
						fieldLabel: '实体简称',
						width:150,
						name: 'DEADLINE_DATE'
					}]
				}
// {
// columnWidth:.33,
// layout: 'form',
// items: [{
//  id: 'CONTRACT_APPENDIX',
//  xtype:'textfield',
//  fieldLabel: '实体一级类型',
//  name: 'CONTRACT_APPENDIX'
// }]
// },
// {
// 	columnWidth:.33,
// 	layout: 'form',
// 	items: [{
// 	id: 'CONTRACT_CONTENTS',
// 	xtype:'textfield',
// 	fieldLabel: '实体二级类型',
// 	name: 'CONTRACT_CONTENTS'
// 	}]
// 	}
				]

			}

			]});

		var tbtnFind = Ext.create("Ext.Button", {
			text: '查询',

			handler: function(){
				var ENTITIES_CODE = Ext.getCmp('entityCode1').getValue();
				var OVERALL_CODE = Ext.getCmp('overallCode').getValue();
				var ENTITIES_FULLNAME = Ext.getCmp('entityName').getValue();
				var ENTITY_ABBREVIATED = Ext.getCmp('entityFullName').getValue();
				var store = Ext.getCmp('monitorAnalyze').getStore();

				store.on('beforeload', function(store,options) {
					var new_params = {
						ENTITIES_CODE : ENTITIES_CODE, OVERALL_CODE:OVERALL_CODE,ENTITIES_FULLNAME:ENTITIES_FULLNAME,ENTITY_ABBREVIATED:ENTITY_ABBREVIATED
					};
					//这里apply一下实现新的proxy
					Ext.apply(store.proxy.extraParams,new_params);
				});
				//对store重新载入
				store.load();
				winFind.close();
			}
		});

		var winFind = Ext.create("Ext.window.Window", {
			title: '查询',
			width: 800,
			height: 400,
			resizable: true,
			modal: true,
			closable: true,
			maximizable: true,
			minimizable: true,
			buttons:[tbtnFind],
			items:[formFind]
		});
		winFind.show();

	}


var tbtn3 = Ext.create("Ext.Button", {
 	text: '编辑信息',
 	handler:function(){
   	 var records = monitorAnalyze.getSelectionModel().getSelection();
   	 if(records.length==0){
     			Ext.Msg.alert("提示","请选择需要编辑的实体记录");return;
     		}
     		if(records.length>1){
     			Ext.Msg.alert("提示","只能编辑一条实体记录");return;
     		}
//       		var tt = Ext.getCmp("ENTITIES_CODE").getStore().findRecord('name','ENTITIES_CODE')


     		var save = Ext.create("Ext.Button", {
				text: '保存',
				handler: function(){
					var ID = Ext.getCmp('ID').getValue();
					var ENTITIES_CODE = Ext.getCmp('ENTITIES_CODE').getValue();
					var OVERALL_CODE =  Ext.getCmp('OVERALL_CODE').getValue();
					var ENTITIES_FULLNAME =  Ext.getCmp('ENTITIES_FULLNAME').getValue();
					var ENTITIES_CLASS =  Ext.getCmp('ENTITIES_CLASS').getValue();
					var GUEST =  Ext.getCmp('GUEST').getValue();
					var CARRIER =  Ext.getCmp('FREIGHTER').getValue();
					var SUPPLIER =  Ext.getCmp('SUPPLIER').getValue();
					var INTERNAL_BRANCH =  Ext.getCmp('INTERNAL_BRANCH').getValue();
					var SETTLEMENT_CATEGORY =  Ext.getCmp('SETTLEMENT_CATEGORY').getValue();
					var BUSINESS_CLASS =  Ext.getCmp('BUSINESS_CLASS').getValue();
					var SOCIAL_CREDIT_CODE =  Ext.getCmp('SOCIAL_CREDIT_CODE').getValue();
					var ENABLE =  Ext.getCmp('ENABLE').getValue();
					var ENTITY_EN_NAME =  Ext.getCmp('ENTITY_EN_NAME').getValue();
					var ENTITY_ABBREVIATED =  Ext.getCmp('ENTITY_ABBREVIATED').getValue();
					var FINANCIAL_CONTACT =  Ext.getCmp('FINANCIAL_CONTACT').getValue();
					var FINANCIAL_CONTACT_PHONE =  Ext.getCmp('FINANCIAL_CONTACT_PHONE').getValue();
					var BANK_ACCOUNT =  Ext.getCmp('BANK_ACCOUNT').getValue();
					var RECEIPTS_PAYMENT_TYPE =  Ext.getCmp('RECEIPTS_PAYMENT_TYPE').getValue();
					var EMAIL =  Ext.getCmp('EMAIL').getValue();
					var BUSINESS_CONTACT =  Ext.getCmp('BUSINESS_CONTACT').getValue();
					var BUSINESS_CONTACT_PHONE =  Ext.getCmp('BUSINESS_CONTACT_PHONE').getValue();
					var ENTITY_SOURCE =  Ext.getCmp('ENTITY_SOURCE').getValue();
					var AMOUNT_RECEIVABLE =  Ext.getCmp('AMOUNT_RECEIVABLE').getValue();
					var ACCOUNTS_RECEIVABLE_PERIOD =  Ext.getCmp('ACCOUNTS_RECEIVABLE_PERIOD').getValue();
					var AMOUNT_PAYABLE =  Ext.getCmp('AMOUNT_PAYABLE').getValue();
					var COPE_DEALLINE =  Ext.getCmp('COPE_DEALLINE').getValue();
					Ext.Ajax.request({
						url: '<%=basePath%>entityMaintain/saveOrUpdateData',
						params:{ID:ID,ENTITIES_CODE:ENTITIES_CODE,OVERALL_CODE:OVERALL_CODE,ENTITIES_FULLNAME:ENTITIES_FULLNAME,ENTITIES_CLASS:ENTITIES_CLASS,GUEST:GUEST,FREIGHTER:CARRIER,SUPPLIER:SUPPLIER,INTERNAL_BRANCH:INTERNAL_BRANCH,SETTLEMENT_CATEGORY:SETTLEMENT_CATEGORY,BUSINESS_CLASS:BUSINESS_CLASS,SOCIAL_CREDIT_CODE:SOCIAL_CREDIT_CODE,ENABLE:ENABLE,ENTITY_EN_NAME:ENTITY_EN_NAME,ENTITY_ABBREVIATED:ENTITY_ABBREVIATED,FINANCIAL_CONTACT:FINANCIAL_CONTACT,FINANCIAL_CONTACT_PHONE:FINANCIAL_CONTACT_PHONE,BANK_ACCOUNT:BANK_ACCOUNT,RECEIPTS_PAYMENT_TYPE:RECEIPTS_PAYMENT_TYPE,EMAIL:EMAIL,BUSINESS_CONTACT:BUSINESS_CONTACT,BUSINESS_CONTACT_PHONE:BUSINESS_CONTACT_PHONE,ENTITY_SOURCE:ENTITY_SOURCE,AMOUNT_RECEIVABLE:AMOUNT_RECEIVABLE,ACCOUNTS_RECEIVABLE_PERIOD:ACCOUNTS_RECEIVABLE_PERIOD,AMOUNT_PAYABLE:AMOUNT_PAYABLE,COPE_DEALLINE:COPE_DEALLINE},
						method: 'POST',
						success: function () {
							Ext.MessageBox.alert("保存成功","保存成功");
							var grid = Ext.getCmp('monitorAnalyze');
							grid.store.reload();
							win11.close();
						}
					});

				}

			}
	);
	var clear = Ext.create("Ext.Button", {
				text: '重置',
				listeners: {
					'click': function () {
						Ext.getCmp('myform').getForm().reset();
					}
				}
			}

	);
	var close = Ext.create("Ext.Button", {
				text: '取消',
				listeners: {
					'click': function () {
						win.close();
					}
				}
			}

	);

	var form = new Ext.create('Ext.form.Panel', {
		id:'myform',
		frame: true,

		items: [{
			layout : 'column',
			items : [
				{
					columnWidth:0,
					layout: 'form',
					items: [{
						id:'ID',
						hidden:true,
						hideLabel:true,
						xtype:'textfield',
						fieldLabel: 'ID',
						name: 'ID'
					}]
				},{
					columnWidth:.33,
					layout: 'form',
					items: [{
						id:'ENTITIES_CODE',
						xtype:'textfield',
						fieldLabel: '实体编码',
						name: 'ENTITIES_CODE'
					}]
				},
				{
					columnWidth:.33,
					layout: 'form',
					items: [{
						id:'ENTITY_EN_NAME',
						xtype:'textfield',
						fieldLabel: '实体英文名称',
						name: 'ENTITY_EN_NAME'
					}]
				},
				{
					columnWidth:.33,
					layout: 'form',
					items: [{
						id:'AMOUNT_RECEIVABLE',
						xtype:'textfield',
						fieldLabel: '应收金额',
						name: 'AMOUNT_RECEIVABLE'
					}]
				}]

		},{
			layout : 'column',
			items : [ {
				columnWidth:.33,
				layout: 'form',
				items: [{
					id:'OVERALL_CODE',
					xtype:'textfield',
					fieldLabel: '总部编码',
					name: 'OVERALL_CODE'
				}]
			},
				{
					columnWidth:.33,
					layout: 'form',
					items: [{
						id:'ENTITY_ABBREVIATED',
						xtype:'textfield',
						fieldLabel: '实体简称',
						name: 'ENTITY_ABBREVIATED'
					}]
				},
				{
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'ACCOUNTS_RECEIVABLE_PERIOD',
						xtype:'textfield',
						fieldLabel: '应收期限',
						name: 'ACCOUNTS_RECEIVABLE_PERIOD'
					}]
				}]

		},
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'ENTITIES_FULLNAME',
						xtype:'textfield',
						fieldLabel: '实体全称',
						name: 'ENTITIES_FULLNAME'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'FINANCIAL_CONTACT',
							xtype:'textfield',
							fieldLabel: '财务联系人',
							name: 'FINANCIAL_CONTACT'
						}]
					},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'AMOUNT_PAYABLE',
							xtype:'textfield',
							fieldLabel: '应付金额',
							name: 'AMOUNT_PAYABLE'
						}]
					}]

			},
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'ENTITIES_CLASS',
						xtype:'textfield',
						fieldLabel: '实体类别',
						name: 'ENTITIES_CLASS',
// listeners: {
//     'click': function () {
//			alert("1");
//     	winPanel.show();

//    }
// }
// handler:function(){
// 	winPanel.show();
// }
						listeners:{
							render:function(p){
								p.getEl().on('click',function(p){
									winPanel.show();
								})
							}
						}
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'FINANCIAL_CONTACT_PHONE',
							xtype:'textfield',
							fieldLabel: '财务联系人电话',
							name: 'FINANCIAL_CONTACT_PHONE'
						}]
					},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'COPE_DEALLINE',
							xtype:'textfield',
							fieldLabel: '应付期限',
							name: 'COPE_DEALLINE'
						}]
					}]

			},
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'GUEST',
						xtype:'textfield',
						fieldLabel: '客户',
						name: 'GUEST',
						readOnly:true,
						emptyText:'请点击实体类别'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'BANK_ACCOUNT',
							xtype:'textfield',
							fieldLabel: '开户行账号',
							name: 'BANK_ACCOUNT'
						}]
					}]

			}
			,
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id:'FREIGHTER',
						xtype:'textfield',
						fieldLabel: '承运人',
						name: 'FREIGHTER',
						readOnly:true,
						emptyText:'请点击实体类别'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'RECEIPTS_PAYMENT_TYPE',
							xtype:'textfield',
							fieldLabel: '收付类型',
							name: 'RECEIPTS_PAYMENT_TYPE'
						}]
					}]

			},
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'SUPPLIER',
						xtype:'textfield',
						fieldLabel: '供应商',
						name: 'SUPPLIER',
						readOnly:true,
						emptyText:'请点击实体类别'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'EMAIL',
							xtype:'textfield',
							fieldLabel: '邮箱',
							name: 'EMAIL'
						}]
					}]

			},
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'INTERNAL_BRANCH',
						xtype:'textfield',
						fieldLabel: '内部分公司',
						emptyText:'请点击实体类别',
						readOnly:true,
						name: 'INTERNAL_BRANCH'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'BUSINESS_CONTACT',
							xtype:'textfield',
							fieldLabel: '业务联系人',
							name: 'BUSINESS_CONTACT'
						}]
					}]

			},
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'SETTLEMENT_CATEGORY',
						xtype:'textfield',
						fieldLabel: '结算类别',
						name: 'SETTLEMENT_CATEGORY'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'BUSINESS_CONTACT_PHONE',
							xtype:'textfield',
							fieldLabel: '业务联系电话',
							name: 'BUSINESS_CONTACT_PHONE'
						}]
					}]

			},
			{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'BUSINESS_CLASS',
						xtype:'textfield',
						fieldLabel: '业务类别',
						name: 'BUSINESS_CLASS'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'ENTITY_SOURCE',
							xtype:'textfield',
							fieldLabel: '实体来源',
							name: 'ENTITY_SOURCE'
						}]
					}]

			},
			{

				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id: 'SOCIAL_CREDIT_CODE',
						xtype:'textfield',
						fieldLabel: '社会信用代码',
						name: 'SOCIAL_CREDIT_CODE'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'ENABLE',
							xtype:'textfield',
							fieldLabel: '是否可用',
							name: 'ENABLE'
						}]
					}]

			}]
	});
	var ID = records[0].data.ID;
//		alert(ID);
		Ext.getCmp("ID").setValue(ID);
		
	var ENTITIES_CODE = records[0].data.ENTITIES_CODE;
		Ext.getCmp("ENTITIES_CODE").setValue(ENTITIES_CODE);
		var OVERALL_CODE = records[0].data.OVERALL_CODE;
		Ext.getCmp("OVERALL_CODE").setValue(OVERALL_CODE);
		
		var ENTITIES_FULLNAME = records[0].data.ENTITIES_FULLNAME;
		Ext.getCmp("ENTITIES_FULLNAME").setValue(ENTITIES_FULLNAME);
		
		var ENTITIES_CLASS = records[0].data.ENTITIES_CLASS;
		Ext.getCmp("ENTITIES_CLASS").setValue(ENTITIES_CLASS);
		
		var GUEST = records[0].data.GUEST;
		Ext.getCmp("GUEST").setValue(GUEST);
		
		var CARRIER = records[0].data.CARRIER;
		Ext.getCmp("FREIGHTER").setValue(CARRIER);
		
		var SUPPLIER = records[0].data.SUPPLIER;
		Ext.getCmp("SUPPLIER").setValue(SUPPLIER);
		
		var INTERNAL_BRANCH = records[0].data.INTERNAL_BRANCH;
		Ext.getCmp("INTERNAL_BRANCH").setValue(INTERNAL_BRANCH);
		
		var SETTLEMENT_CATEGORY = records[0].data.SETTLEMENT_CATEGORY;
		Ext.getCmp("SETTLEMENT_CATEGORY").setValue(SETTLEMENT_CATEGORY);
		
		var BUSINESS_CLASS = records[0].data.BUSINESS_CLASS;
		Ext.getCmp("BUSINESS_CLASS").setValue(BUSINESS_CLASS);
		
		var SOCIAL_CREDIT_CODE = records[0].data.SOCIAL_CREDIT_CODE;
		Ext.getCmp("SOCIAL_CREDIT_CODE").setValue(SOCIAL_CREDIT_CODE);
		
		var ENABLE = records[0].data.ENABLE;
		Ext.getCmp("ENABLE").setValue(ENABLE);
		
		var ENTITY_ABBREVIATED = records[0].data.ENTITY_ABBREVIATED;
		Ext.getCmp("ENTITY_ABBREVIATED").setValue(ENTITY_ABBREVIATED);
		
		var FINANCIAL_CONTACT = records[0].data.FINANCIAL_CONTACT;
		Ext.getCmp("FINANCIAL_CONTACT").setValue(FINANCIAL_CONTACT);
		
		var FINANCIAL_CONTACT_PHONE = records[0].data.FINANCIAL_CONTACT_PHONE;
		Ext.getCmp("FINANCIAL_CONTACT_PHONE").setValue(FINANCIAL_CONTACT_PHONE);
		
		var BANK_ACCOUNT = records[0].data.BANK_ACCOUNT;
		Ext.getCmp("BANK_ACCOUNT").setValue(BANK_ACCOUNT);
		
		var RECEIPTS_PAYMENT_TYPE = records[0].data.RECEIPTS_PAYMENT_TYPE;
		Ext.getCmp("RECEIPTS_PAYMENT_TYPE").setValue(RECEIPTS_PAYMENT_TYPE);
		
		var EMAIL = records[0].data.EMAIL;
		Ext.getCmp("EMAIL").setValue(EMAIL);
		
		var BUSINESS_CONTACT = records[0].data.BUSINESS_CONTACT;
		Ext.getCmp("BUSINESS_CONTACT").setValue(BUSINESS_CONTACT);
		
		var BUSINESS_CONTACT_PHONE = records[0].data.BUSINESS_CONTACT_PHONE;
		Ext.getCmp("BUSINESS_CONTACT_PHONE").setValue(BUSINESS_CONTACT_PHONE);
		
		var ENTITY_SOURCE = records[0].data.ENTITY_SOURCE;
		Ext.getCmp("ENTITY_SOURCE").setValue(ENTITY_SOURCE);
		
		var AMOUNT_RECEIVABLE = records[0].data.AMOUNT_RECEIVABLE;
		Ext.getCmp("AMOUNT_RECEIVABLE").setValue(AMOUNT_RECEIVABLE);
		
		var ACCOUNTS_RECEIVABLE_PERIOD = records[0].data.ACCOUNTS_RECEIVABLE_PERIOD;
		Ext.getCmp("ACCOUNTS_RECEIVABLE_PERIOD").setValue(ACCOUNTS_RECEIVABLE_PERIOD);
		
		var AMOUNT_PAYABLE = records[0].data.AMOUNT_PAYABLE;
		Ext.getCmp("AMOUNT_PAYABLE").setValue(AMOUNT_PAYABLE);
		
		var COPE_DEALLINE = records[0].data.COPE_DEALLINE;
		Ext.getCmp("COPE_DEALLINE").setValue(COPE_DEALLINE);
	var win11 = Ext.create("Ext.window.Window", {
		title: '修改实体',
		width: 800,
		height: 500,
		resizable: true,
		modal: true,
		closable: true,
		maximizable: true,
		minimizable: true,
		buttons:[save,clear,close],
		items:[form]
	});
	win11.show();
 	}
}
);





             

//	添加实体
	function addEntities(){

		var save = Ext.create("Ext.Button", {
					text: '保存',
					handler: function(){
						var ID = Ext.getCmp('ID').getValue();
						var ENTITIES_CODE = Ext.getCmp('ENTITIES_CODE').getValue();
						var OVERALL_CODE =  Ext.getCmp('OVERALL_CODE').getValue();
						var ENTITIES_FULLNAME =  Ext.getCmp('ENTITIES_FULLNAME').getValue();
						var ENTITIES_CLASS =  Ext.getCmp('ENTITIES_CLASS').getValue();
						var GUEST =  Ext.getCmp('GUEST').getValue();
						var CARRIER =  Ext.getCmp('FREIGHTER').getValue();
						var SUPPLIER =  Ext.getCmp('SUPPLIER').getValue();
						var INTERNAL_BRANCH =  Ext.getCmp('INTERNAL_BRANCH').getValue();
						var SETTLEMENT_CATEGORY =  Ext.getCmp('SETTLEMENT_CATEGORY').getValue();
						var BUSINESS_CLASS =  Ext.getCmp('BUSINESS_CLASS').getValue();
						var SOCIAL_CREDIT_CODE =  Ext.getCmp('SOCIAL_CREDIT_CODE').getValue();
						var ENABLE =  Ext.getCmp('ENABLE').getValue();
						var ENTITY_EN_NAME =  Ext.getCmp('ENTITY_EN_NAME').getValue();
						var ENTITY_ABBREVIATED =  Ext.getCmp('ENTITY_ABBREVIATED').getValue();
						var FINANCIAL_CONTACT =  Ext.getCmp('FINANCIAL_CONTACT').getValue();
						var FINANCIAL_CONTACT_PHONE =  Ext.getCmp('FINANCIAL_CONTACT_PHONE').getValue();
						var BANK_ACCOUNT =  Ext.getCmp('BANK_ACCOUNT').getValue();
						var RECEIPTS_PAYMENT_TYPE =  Ext.getCmp('RECEIPTS_PAYMENT_TYPE').getValue();
						var EMAIL =  Ext.getCmp('EMAIL').getValue();
						var BUSINESS_CONTACT =  Ext.getCmp('BUSINESS_CONTACT').getValue();
						var BUSINESS_CONTACT_PHONE =  Ext.getCmp('BUSINESS_CONTACT_PHONE').getValue();
						var ENTITY_SOURCE =  Ext.getCmp('ENTITY_SOURCE').getValue();
						var AMOUNT_RECEIVABLE =  Ext.getCmp('AMOUNT_RECEIVABLE').getValue();
						var ACCOUNTS_RECEIVABLE_PERIOD =  Ext.getCmp('ACCOUNTS_RECEIVABLE_PERIOD').getValue();
						var AMOUNT_PAYABLE =  Ext.getCmp('AMOUNT_PAYABLE').getValue();
						var COPE_DEALLINE =  Ext.getCmp('COPE_DEALLINE').getValue();
						var IS_INNER_SETTLEMENT = Ext.getCmp('IS_INNER_SETTLEMENT').getValue();
						Ext.Ajax.request({
							url: '<%=basePath%>entityMaintain/saveOrUpdateData',
							params:{ID:ID,ENTITIES_CODE:ENTITIES_CODE,OVERALL_CODE:OVERALL_CODE,ENTITIES_FULLNAME:ENTITIES_FULLNAME,ENTITIES_CLASS:ENTITIES_CLASS,GUEST:GUEST,FREIGHTER:CARRIER,SUPPLIER:SUPPLIER,INTERNAL_BRANCH:INTERNAL_BRANCH,SETTLEMENT_CATEGORY:SETTLEMENT_CATEGORY,BUSINESS_CLASS:BUSINESS_CLASS,SOCIAL_CREDIT_CODE:SOCIAL_CREDIT_CODE,ENABLE:ENABLE,ENTITY_EN_NAME:ENTITY_EN_NAME,ENTITY_ABBREVIATED:ENTITY_ABBREVIATED,FINANCIAL_CONTACT:FINANCIAL_CONTACT,FINANCIAL_CONTACT_PHONE:FINANCIAL_CONTACT_PHONE,BANK_ACCOUNT:BANK_ACCOUNT,RECEIPTS_PAYMENT_TYPE:RECEIPTS_PAYMENT_TYPE,EMAIL:EMAIL,BUSINESS_CONTACT:BUSINESS_CONTACT,BUSINESS_CONTACT_PHONE:BUSINESS_CONTACT_PHONE,ENTITY_SOURCE:ENTITY_SOURCE,AMOUNT_RECEIVABLE:AMOUNT_RECEIVABLE,ACCOUNTS_RECEIVABLE_PERIOD:ACCOUNTS_RECEIVABLE_PERIOD,AMOUNT_PAYABLE:AMOUNT_PAYABLE,COPE_DEALLINE:COPE_DEALLINE,IS_INNER_SETTLEMENT:IS_INNER_SETTLEMENT},
							method: 'POST',
							success: function () {
								Ext.MessageBox.alert("保存成功","保存成功");
								var grid = Ext.getCmp('monitorAnalyze');
								grid.store.reload();
								win.close();
							}
						});

					}

				}
		);
		var clear = Ext.create("Ext.Button", {
					text: '重置',
					listeners: {
						'click': function () {
							Ext.getCmp('myform').getForm().reset();
						}
					}
				}

		);
		var close = Ext.create("Ext.Button", {
					text: '取消',
					listeners: {
						'click': function () {
							win.close();
						}
					}
				}

		);

		var form = new Ext.create('Ext.form.Panel', {
			id:'myform',
			frame: true,

			items: [{
				layout : 'column',
				items : [
					{
						columnWidth:0,
						layout: 'form',
						items: [{
							id:'ID',
							hidden:true,
							hideLabel:true,
							xtype:'textfield',
							fieldLabel: 'ID',
							name: 'ID'
						}]
					},{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'ENTITIES_CODE',
							xtype:'textfield',
							fieldLabel: '实体编码',
							name: 'ENTITIES_CODE'
						}]
					},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'ENTITY_EN_NAME',
							xtype:'textfield',
							fieldLabel: '实体英文名称',
							name: 'ENTITY_EN_NAME'
						}]
					},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'AMOUNT_RECEIVABLE',
							xtype:'textfield',
							fieldLabel: '应收金额',
							name: 'AMOUNT_RECEIVABLE'
						}]
					}]

			},{
				layout : 'column',
				items : [ {
					columnWidth:.33,
					layout: 'form',
					items: [{
						id:'OVERALL_CODE',
						xtype:'textfield',
						fieldLabel: '总部编码',
						name: 'OVERALL_CODE'
					}]
				},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'ENTITY_ABBREVIATED',
							xtype:'textfield',
							fieldLabel: '实体简称',
							name: 'ENTITY_ABBREVIATED'
						}]
					},
					{
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'ACCOUNTS_RECEIVABLE_PERIOD',
							xtype:'textfield',
							fieldLabel: '应收期限',
							name: 'ACCOUNTS_RECEIVABLE_PERIOD'
						}]
					}]

			},
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'ENTITIES_FULLNAME',
							xtype:'textfield',
							fieldLabel: '实体全称',
							name: 'ENTITIES_FULLNAME'
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'FINANCIAL_CONTACT',
								xtype:'textfield',
								fieldLabel: '财务联系人',
								name: 'FINANCIAL_CONTACT'
							}]
						},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'AMOUNT_PAYABLE',
								xtype:'textfield',
								fieldLabel: '应付金额',
								name: 'AMOUNT_PAYABLE'
							}]
						}]

				},
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'ENTITIES_CLASS',
							xtype:'textfield',
							fieldLabel: '实体类别',
							name: 'ENTITIES_CLASS',
//     listeners: {
//         'click': function () {
// 			alert("1");
//         	winPanel.show();

//        }
//     }
//     handler:function(){
//     	winPanel.show();
//     }
							listeners:{
								render:function(p){
									p.getEl().on('click',function(p){
										winPanel.show();
									})
								}
							}
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'FINANCIAL_CONTACT_PHONE',
								xtype:'textfield',
								fieldLabel: '财务联系人电话',
								name: 'FINANCIAL_CONTACT_PHONE'
							}]
						},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'COPE_DEALLINE',
								xtype:'textfield',
								fieldLabel: '应付期限',
								name: 'COPE_DEALLINE'
							}]
						}]

				},
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'GUEST',
							xtype:'textfield',
							fieldLabel: '客户',
							name: 'GUEST',
							readOnly:true,
							emptyText:'请点击实体类别'
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'BANK_ACCOUNT',
								xtype:'textfield',
								fieldLabel: '开户行账号',
								name: 'BANK_ACCOUNT'
							}]
						}]

				}
				,
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id:'FREIGHTER',
							xtype:'textfield',
							fieldLabel: '承运人',
							name: 'FREIGHTER',
							readOnly:true,
							emptyText:'请点击实体类别'
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'RECEIPTS_PAYMENT_TYPE',
								xtype:'textfield',
								fieldLabel: '收付类型',
								name: 'RECEIPTS_PAYMENT_TYPE'
							}]
						}]

				},
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'SUPPLIER',
							xtype:'textfield',
							fieldLabel: '供应商',
							name: 'SUPPLIER',
							readOnly:true,
							emptyText:'请点击实体类别'
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'EMAIL',
								xtype:'textfield',
								fieldLabel: '邮箱',
								name: 'EMAIL'
							}]
						}]

				},
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'INTERNAL_BRANCH',
							xtype:'textfield',
							fieldLabel: '内部分公司',
							emptyText:'请点击实体类别',
							readOnly:true,
							name: 'INTERNAL_BRANCH'
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'BUSINESS_CONTACT',
								xtype:'textfield',
								fieldLabel: '业务联系人',
								name: 'BUSINESS_CONTACT'
							}]
						}]

				},
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'SETTLEMENT_CATEGORY',
							xtype:'textfield',
							fieldLabel: '结算类别',
							name: 'SETTLEMENT_CATEGORY'
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'BUSINESS_CONTACT_PHONE',
								xtype:'textfield',
								fieldLabel: '业务联系电话',
								name: 'BUSINESS_CONTACT_PHONE'
							}]
						}]

				},
				{
					layout : 'column',
					items : [ {
						columnWidth:.33,
						layout: 'form',
						items: [{
							id: 'BUSINESS_CLASS',
							xtype:'textfield',
							fieldLabel: '业务类别',
							name: 'BUSINESS_CLASS'
						}]
					},
						{
							columnWidth:.33,
							layout: 'form',
							items: [{
								id: 'ENTITY_SOURCE',
								xtype:'textfield',
								fieldLabel: '实体来源',
								name: 'ENTITY_SOURCE'
							}]
						}]

				},
				{

					items : [ {
						columnWidth:0.33,
						layout: 'form',
						items: [{
							id: 'SOCIAL_CREDIT_CODE',
							xtype:'textfield',
							fieldLabel: '社会信用代码',
							name: 'SOCIAL_CREDIT_CODE'
						}]
					},
						{
							columnWidth:0.33,
							layout: 'form',
							items: [{
								id: 'ENABLE',
								xtype:'textfield',
								fieldLabel: '是否可用',
								name: 'ENABLE'
							}]
						},{
							columnWidth:0.33,
							layout: 'form',
							items: [{
								id: 'IS_INNER_SETTLEMENT',
								xtype:'textfield',
								fieldLabel: '是否公司内部部门',
								name: 'IS_INNER_SETTLEMENT'
							}]
						}]

				}]
		});

		var win = Ext.create("Ext.window.Window", {
			title: '新增实体',
			width: 800,
			height: 500,
			resizable: true,
			modal: true,
			closable: true,
			maximizable: true,
			minimizable: true,
			buttons:[save,clear,close],
			items:[form]
		});
		win.show();
	}



//              var panel = new Ext.Panel({
//                  items: [monitorAnalyze,contractInfo]
//          })  ;

	var monitorAnalyze = new Ext.grid.GridPanel({
		title : '实体维护',
		id : 'monitorAnalyze',
		store : store,
// 		sm : sm,
// 		cm : cm,
		region:'north',
// 		height:'55%',
		loadMask : true,
		trackMouseOver : false,
		selModel:sm,
		viewConfig : {
			forceFit : false
		},
		tbar: [tbtn,tbtn2,tbtn3,tbtn4,{width:250,fieldLabel:'简单查询',labelWidth:80,id:'entityCode',xtype:'textfield',store:store,emptyText:'客户编码'},Ext.create("Ext.Button", {
			
		 	text: '查询',
		 	handler: function(){
		 		var store = Ext.getCmp('monitorAnalyze').getStore();
		 		var ENTITIES_CODE = Ext.getCmp('entityCode').getValue();
		 		store.on('beforeload', function(store,options) {  
		            var new_params = {  
		            		ENTITIES_CODE : ENTITIES_CODE
		            };  
			//这里apply一下实现新的proxy  
		            Ext.apply(store.proxy.extraParams,new_params);  
		        });  
		 		 store.load();
		}
		})],
// 		bodyStyle : 'width:100%',
// 		autoWidth : true,
// 		enableColumnResize : true,
		height : 325,
		colModel:cm,
		bbar : new Ext.PagingToolbar({
			pageSize : 12,
			store : store,
			displayInfo : true,
			emptyMsg : "<span style='color:red'>没有查询到符合的记录</span>"
		}),
		renderTo : 'gsmLacciDayList',
		 listeners:{  
			//单击  rowclick
			        'cellclick': function(grid,row){  
			    	   var rs=monitorAnalyze.getSelectionModel().getSelection();
			    	   
			    	   Ext.each(rs,function(){
			    		   var ID = this.get("ID");
			    		   var store = Ext.getCmp('contractInfo').getStore();
						var FAST_SEARCH_CODE = ID;

　　					store.on('beforeload', function(store,options) {  
				            var new_params1 = {  
				            		ENTITY_ID : FAST_SEARCH_CODE
				            };  
				　　//这里apply一下实现新的proxy  
				            Ext.apply(store.proxy.extraParams,new_params1);  
				        });  
						store.load();  
		       				var store1 = Ext.getCmp('invoice_title').getStore();
						
						var id = ID;
		       			　　store1.on('beforeload', function(store,options) {  
				            var new_params = {  
				            		ENTITY_ID : id
				            };  
				　　//这里apply一下实现新的proxy  
				            Ext.apply(store1.proxy.extraParams,new_params);  
				        }); 
		       			store1.load();  
			    		   })
			       }  
	     }
			
	});
	
	monitorAnalyze.getStore().reload();
	/**>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>实体信息js结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
	
	/**>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>合同信息js开始<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
	var ct = [
	                                   new Ext.grid.RowNumberer({
	                                	   
	                                	   header : "序号",
	                                	   width : 50,
	                                   }),
	                                   
	                                   {
										  		header : "ID",
										  		tooltip : "ID",
										  		width : 140,
										  		sortable : true,
										  		align:"left",
										  		hidden:true,
										  		dataIndex : 'ID'
										  	},
	                                  	{
	                                  		header : "合同编号",
	                                  		tooltip : "合同编号",
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'CONTRACT_NUM'
	                                  	},
	                                  	{
	                                  		header : "业务类型",
	                                  		tooltip : "业务类型",
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'BUSINESS_CLASS_ID'
	                                  	},
	                                  	{
	                                  		header : "合同开始日期",
	                                  		tooltip : "合同开始日期",
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'REGISTRATION_DATE',
// 	                                  		editor:{xtype: 'datefield',format: 'Y-m-d'},renderer : Ext.util.Format.dateRenderer('Y-m-d')
	                                  	},
	                                  	{
	                                  		header : "合同结束日期",
	                                  		tooltip : "合同结束日期",
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'DEADLINE_DATE',
// 	                                  		editor:{xtype: 'datefield',format: 'Y-m-d'},renderer : Ext.util.Format.dateRenderer('Y-m-d')
	                                  	},
	                                  	{
	                                  		header : "合同更新日期",
	                                  		tooltip : "实体编码",
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'UPDATE_DATE',
// 	                                  		editor:{xtype: 'datefield',format: 'Y-m-d'},renderer : Ext.util.Format.dateRenderer('Y-m-d')
	                                  	},
	                                  	{
	                                  		header : "文件",
	                                  		tooltip : "文件",
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'CONTRACT_APPENDIX'
	                                  	},
	                                	{
	                                  		header : "合同内容",
	                                  		tooltip : "合同内容",
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'CONTRACT_CONTENTS'
	                                  	},{
	                                  		header : "ENTITY_ID",
	                                  		tooltip : "ENTITY_ID",
	                                  		hidden:true,
	                                  		width : 140,
	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'ENTITY_ID'
	                                  	}
	                                  	];
  
Ext.define('store1', {
			extend : 'Ext.data.Model',
			fields :[
			    	    {
			    	   	    name: 'ID'
			    	   	},{
			    	   	    name: 'CONTRACT_NUM'
			    	   	},{
			    	   	    name : 'BUSINESS_CLASS_ID'
			    	   	},{
			    	   	    name : 'REGISTRATION_DATE',
//			    	    	    type : 'date',dateFormat:'Y-m-d'
			    	   	}
			    	   	,{
			    	   	    name : 'DEADLINE_DATE',
//			    	    	    type : 'date',dateFormat:'Y-m-d'
			    	   	}
			    	   	,{
			    	   	    name : 'UPDATE_DATE',
//			    	    	    type : 'date',dateFormat:'Y-m-d'
			    	   	}
			    	   	,{
			    	   	    name : 'CONTRACT_APPENDIX'
			    	   	}
			    	   	,{
			    	   	    name : 'CONTRACT_CONTENTS'
			    	   	},{
			    	   	    name : 'ENTITY_ID'
			    	   	}
			    	   	
			    	   	]
		});


	  var store1 = Ext.create('Ext.data.Store', {
			model : 'store1',
			pageSize:10,
//			pageSize : thePageSize,
			id:'store1',
			proxy : {
				type : 'ajax',
				actionMethods : {
					read : 'POST'
				},//将提交方式改为post
				url: '<%=basePath%>entityMaintain/contractInfo',
				reader : {
					type : 'json',
					root : 'result.list',
					totalProperty:'result.total'
// 					root : 'row',
// 					totalProperty:'total'
				}
			}
		});
 	var save1 = new Ext.Button({
     	text: '保存',
     	 handler: function(){
     		var form = Ext.getCmp('myform1').getForm();
     		var ID = Ext.getCmp('ID').getValue();
     		var CONTRACT_NUM = Ext.getCmp('CONTRACT_NUM').getValue();
     		var CONTRACT_APPENDIX =  Ext.getCmp('CONTRACT_APPENDIX').getValue();
     		var BUSINESS_CLASS =  Ext.getCmp('BUSINESS_CLASS').getValue();
//      		var REGISTRATION_DATE =  Ext.getCmp('REGISTRATION_DATE').getValue();
     		var REGISTRATION_DATE =Ext.util.Format.date(form.findField("REGISTRATION_DATE").value,'Y-m-d');
//      		var DEADLINE_DATE =  Ext.getCmp('DEADLINE_DATE').getValue();
     		var DEADLINE_DATE =Ext.util.Format.date(form.findField("REGISTRATION_DATE").value,'Y-m-d');
     		var CONTRACT_CONTENTS =  Ext.getCmp('CONTRACT_CONTENTS').getValue();
//      		var UPDATE_DATE =  Ext.getCmp('UPDATE_DATE').getValue();
			 var rs=monitorAnalyze.getSelectionModel().getSelection();
			    	   
			    	   Ext.each(rs,function(){
			    		   var ENTITY_ID = this.get("ID");
			    		   Ext.Ajax.request({
			       			 url: '<%=basePath%>entityMaintain/saveOrUpdateContractData',
			       			 params:{ID:ID,CONTRACT_NUM:CONTRACT_NUM,CONTRACT_APPENDIX:CONTRACT_APPENDIX,BUSINESS_CLASS:BUSINESS_CLASS,REGISTRATION_DATE:REGISTRATION_DATE,DEADLINE_DATE:DEADLINE_DATE,CONTRACT_CONTENTS:CONTRACT_CONTENTS,ENTITY_ID:ENTITY_ID},
			       			 method: 'POST',
			       			success: function () {
			                      Ext.MessageBox.alert("保存成功","保存成功");
			                      var grid = Ext.getCmp('contractInfo');
			  					 grid.store.reload();
			  					 win1.close();
			                  },
			       		 });
			    		   })
     		 

     	 }

   	}
 	
  );
	var clear1 = new Ext.Button({
     	text: '重置',
     	listeners: {
         'click': function () {
        	 Ext.getCmp('myform1').getForm().reset();
        }
     }
  }
   	
  );
	var close1 = new Ext.Button({
     	text: '取消',
     	listeners: {
         'click': function () {
        	 win.close();
        }
     }
  }
   	
  );

var tbtn11 = new Ext.Button({
                 	text: '新增合同',
                 	listeners: {
                     'click': function () {
//                          var row = monitorAnalyze.getSelectionModel().getSelections();
//                         for (var i = 0; i < row.length; i++) {
//                             alert(row[i].get('id'));
//                          }
						var records = monitorAnalyze.getSelectionModel().getSelection();
						if(records.length==0){
  		       				Ext.Msg.alert("提示","请选择需要新增合同的实体");return;
  		       			}
  		       			if(records.length>1){
  		       				Ext.Msg.alert("提示","只能选择一个实体进行增加合同操作");return;
  		       			}
							 win1.show();

                    	
//                     	 form.show();
                    }
                 }
              }
              );
var tbtn12 = new Ext.Button({
 	text: '删除合同',
 	handler: function(){
 		var records = contractInfo.getSelectionModel().getSelection();
 		if(records.length==0){
 				Ext.Msg.alert("提示","请选中需要删除的合同");return;
 			}
 			var arr = [];
 			Ext.each(records,function(item){
 				obj = {
 						id:item.data.ID
 						
 				};
//  				alert(item.data.ID);
 				arr.push(obj);
 				
 			});
 			var array = JSON.stringify(arr);
 			Ext.Ajax.request({
 						url: '<%=basePath%>entityMaintain/deleteContractInfo',
						params:{
// 							records:Ext.JSON.encode(arr)
							array:array
								
						},
						timeout:5000,
						success:function(response){
							 Ext.MessageBox.alert("删除","删除成功");
							 var grid = Ext.getCmp('contractInfo');
							 grid.store.reload();
						},
						
					});
 	}
}
);
var tbtn13 = new Ext.Button({
 	text: '编辑合同',
 	handler:function(){
   	 var records = contractInfo.getSelectionModel().getSelection();
   	 if(records.length==0){
     			Ext.Msg.alert("提示","请选择需要编辑的合同");return;
     		}
     		if(records.length>1){
     			Ext.Msg.alert("提示","只能编辑一条合同");return;
     		}
//       		var tt = Ext.getCmp("ENTITIES_CODE").getStore().findRecord('name','ENTITIES_CODE')
			var ID = records[0].data.ID;
     		Ext.getCmp("ID").setValue(ID);
     		
			var CONTRACT_NUM = records[0].data.CONTRACT_NUM;
     		Ext.getCmp("CONTRACT_NUM").setValue(CONTRACT_NUM);
     		var CONTRACT_APPENDIX = records[0].data.CONTRACT_APPENDIX;
     		Ext.getCmp("CONTRACT_APPENDIX").setValue(CONTRACT_APPENDIX);
     		
     		var BUSINESS_CLASS = records[0].data.BUSINESS_CLASS;
     		Ext.getCmp("BUSINESS_CLASS").setValue(BUSINESS_CLASS);
     		
     		var REGISTRATION_DATE = records[0].data.REGISTRATION_DATE;
     		var dt = new Date(REGISTRATION_DATE);
     		Ext.getCmp("REGISTRATION_DATE").setValue(dt);
     		
     		var DEADLINE_DATE = records[0].data.DEADLINE_DATE;
     		var tt = new Date(DEADLINE_DATE);
     		Ext.getCmp("DEADLINE_DATE").setValue(tt);
     		
     		var CONTRACT_CONTENTS = records[0].data.CONTRACT_CONTENTS;
     		Ext.getCmp("CONTRACT_CONTENTS").setValue(CONTRACT_CONTENTS);
     		
//      		var UPDATE_DATE = records[0].data.UPDATE_DATE;
//      		Ext.getCmp("UPDATE_DATE").setValue(UPDATE_DATE);
     		
     	
   	 		win1.show();
 	}
}
);
// Ext.override(Ext.menu.DateMenu, {  
// 	    render : function() {  
// 	        Ext.menu.DateMenu.superclass.render.call(this);  
// 	        if (Ext.isGecko || Ext.isSafari || Ext.isChrome) {  
// 	            this.picker.el.dom.childNodes[0].style.width = '178px';  
// 	            this.picker.el.dom.style.width = '178px';  
// 	        }  
// 	    }  
// 	});  
// var tt= new Ext.form.DateField({  
//     fieldLabel : '结束时间',  
//     name : 'endTime',  
//     id : 'endTimeId',  
//     enableKeyEvents : true,  
//     width : 110,  
//     format : 'Y-m-d H:i:s',  
//    value:new Date()  
//    }) 
var form1 = Ext.create('Ext.form.Panel', {
	id:'myform1',
     frame: true,

    items: [{ 
		 layout : 'column', 
			items : [ 
			          {
        columnWidth:0,
        layout: 'form',
        items: [{
        	id:'ID',
        	hidden:true,
        	hideLabel:true,
            xtype:'textfield',
            fieldLabel: 'ID',
            name: 'ID'
        }]
    },{
        columnWidth:.33,
        layout: 'form',
        items: [{
        	id:'CONTRACT_NUM',
            xtype:'textfield',
            fieldLabel: '合同编号',
            name: 'CONTRACT_NUM'
        }]
    },
    {
        columnWidth:.33,
        layout: 'form',
        items: [{
        	id:'BUSINESS_CLASS',
        	xtype: 'textfield',
            fieldLabel: '业务类型',
            name: 'BUSINESS_CLASS'
        }]
    },
    {
        columnWidth:.33,
        layout: 'form',
        items: [{
        	id:'REGISTRATION_DATE',
            xtype:'datefield',
            fieldLabel: '合同开始日期',
            name: 'REGISTRATION_DATE',
            width:150,
            format:'Y-m-d'
        }
        ]
    }]

},{ 
 layout : 'column', 
	items : [ {
columnWidth:.33,
layout: 'form',
items: [{
 id:'DEADLINE_DATE',
 xtype:'datefield',
 fieldLabel: '合同结束日期',
 width:150,
 name: 'DEADLINE_DATE',
 format:'Y-m-d'
}]
},
{
columnWidth:.33,
layout: 'form',
items: [{
 id: 'CONTRACT_APPENDIX',
 xtype:'textfield',
 fieldLabel: '文件',
 name: 'CONTRACT_APPENDIX'
}]
},
{
	columnWidth:.33,
	layout: 'form',
	items: [{
	id: 'CONTRACT_CONTENTS',
	xtype:'textfield',
	fieldLabel: '合同内容',
	name: 'CONTRACT_CONTENTS'
	}]
	}]

},

 ]});
var win1 = Ext.create("Ext.window.Window", {
    title: '新增合同',
    width: 800,
    height: 400,
   resizable: true,
   closeAction :'hide',
    modal: true,
   closable: true,
   maximizable: true,
   minimizable: true,
   buttons:[save1,clear1,close1],
   items:[form1],
});
	var contractInfo = new Ext.grid.GridPanel({
		title : '合同信息',
		id : 'contractInfo',
		store : store1,
// 		cm : ct,
		columns:ct,
		region:'center',
// 		selModel: sm,
		loadMask : true,
		trackMouseOver : false,
		viewConfig : {
			forceFit : false
		},
		bbar :new Ext.PagingToolbar({
			pageSize : 12,
			store : store1,
			displayInfo : true,
			emptyMsg : "<span style='color:red'>没有查询到符合的记录</span>"
		}),
		tbar: [tbtn11,tbtn12,tbtn13,{width:250,fieldLabel:'简单查询',labelWidth:80,id:'contractCode',xtype:'textfield',store:store,emptyText:'合同号'},Ext.create("Ext.Button", {
			
		 	text: '查询',
		 	handler: function(){
		 		var contractCode = Ext.getCmp('contractCode').getValue();
		 		var store = Ext.getCmp('contractInfo').getStore();
		 		store.on('beforeload', function(store,options) {  
		            var new_params = {  
		            		CONTRACT_NUM : contractCode
		            };  
			//这里apply一下实现新的proxy  
		            Ext.apply(store.proxy.extraParams,new_params);  
		        });  
			//对store重新载入  
		        store.load(); 

		}})],
// 		bodyStyle : 'width:100%',
// 		autoWidth : true,
// 		enableColumnResize : true,
// 		height : 325,
		selModel : Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}),
		renderTo : 'contractInfo'
			
	});
	contractInfo.getStore().reload();

	/**>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>合同信息js结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
	
	/**>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>发票抬头维护js开始<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
var cv = [
                                   new Ext.grid.RowNumberer(),
                                   {
								  		header : "ID",
								  		tooltip : "ID",
								  		width : 140,
// 								  		sortable : true,
								  		align:"left",
								  		hidden:true,
								  		dataIndex : 'ID'
								  	},
	                                  	{
	                                  		header : "实体全称",
	                                  		tooltip : "实体全程",
	                                  		width : 140,
// 	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'ENTITIES_FULLNAME',
// 	                                  		editor:new Ext.form.TextField() 
	                                  		 editor : new Ext.form.TextField({
	                                             allowBlank : false              //是否允许为空,默认编辑状态下都是文本框,如果需要别的,需指定xtype类型,见时间和状态列
	                                         }),
	                                  	},
	                                  	{
	                                  		header : "发票抬头",
	                                  		tooltip : "发票抬头",
	                                  		width : 140,
// 	                                  		sortable : true,
	                                  		align:"left",
	                                  		dataIndex : 'INVOICE_TITLE',
// 	                                  		editor:new 	Ext.form.TextField()
	                                  		 editor : new Ext.form.TextField({
	                                             allowBlank : false              //是否允许为空,默认编辑状态下都是文本框,如果需要别的,需指定xtype类型,见时间和状态列
	                                         }),
	                                  	}
	                                  	];

//    	var reader2 = new Ext.data.JsonReader({
//    		root : 'rows',
//    		totalProperty : 'total'
//    	}, [{
//    		name:'ID'
//    	},{
//    	    name: 'ENTITIES_FULLNAME'
//    	},{
//    	    name : 'INVOICE_TITLE'
//    	}
   	
//    	]);
	  Ext.define('store2', {
			extend : 'Ext.data.Model',
			fields :[{
		   		name:'ID'
		   	},{
		   	    name: 'ENTITIES_FULLNAME'
		   	},{
		   	    name : 'INVOICE_TITLE'
		   	}
		   	
		   	]
		});
//    	var store2 =  new Ext.data.Store({
<%--  		url: '<%=basePath%>entityMaintain/invoiceTitleInfo',			 --%>
// 		reader : reader2
// })
	  var store2 = Ext.create('Ext.data.Store', {
			model : 'store2',
			pageSize:10,
//			pageSize : thePageSize,
			id:'store2',
			proxy : {
				type : 'ajax',
				actionMethods : {
					read : 'POST'
				},//将提交方式改为post
				url: '<%=basePath%>entityMaintain/invoiceTitleInfo',
				reader : {
					type : 'json',
					root : 'rows',totalProperty:'total'
				}
			}
		});
   	var tbtn111 = new Ext.Button({
     	text: '新增',
     	listeners: {
         'click': function () {
//              var row = monitorAnalyze.getSelectionModel().getSelections();
//             for (var i = 0; i < row.length; i++) {
//                 alert(row[i].get('id'));
//              }
			var records = monitorAnalyze.getSelectionModel().getSelection();
			if(records.length==0){
     				Ext.Msg.alert("提示","请选择需要新增合同的实体");return;
     			}
     			if(records.length>1){
     				Ext.Msg.alert("提示","只能选择一个实体进行增加合同操作");return;
     			}
     			store2.insert(store2.getCount(),{
	       				xh:store2.getCount(),ENTITIES_FULLNAME:records[0].data.ENTITIES_FULLNAME,INVOICE_TITLE:'',ID:''
	       			});
//      			invoice_title.stopEditing();  
//      			store2.insert(0, p);   
//                 invoice_title.startEditing(0, 0);  //激活该行的编辑状态  

        	
//         	 form.show();
        }
     }
  }
  );
   	var tbtn333 = new Ext.Button({
     	text: '保存',
     	listeners: {
         'click': function () {

        	 var records = invoice_title.getSelectionModel().getSelection();
        	 if(records.length==0){
     			Ext.Msg.alert("提示","无更新的数据");return;
     		}
     		var modifycount = 0;
     		var arr = [];
     		Ext.each(records,function(item){
     			obj = {
     					ID:item.data.ID,
     					ENTITIES_FULLNAME:item.data.ENTITIES_FULLNAME,
     					INVOICE_TITLE:item.data.INVOICE_TITLE
     			};
     			arr.push(obj);
     		});
     		for(var i=0;i<arr.length;i++){
     			if(arr[i].unit_rise==''){
     				Ext.Msg.alert("提示","请完善发票抬头信息");return;
     			}
     		}
     		 var rs=monitorAnalyze.getSelectionModel().getSelection();
	    	   
	    	   Ext.each(rs,function(){
	    		   var ENTITY_ID = this.get("ID");
	    		   alert(ENTITY_ID);
	    		   Ext.Ajax.request({
	        			url: '<%=basePath%>entityMaintain/saveInvoiceInfo',
	   	  		    method:'post',
	   	  			timeout:6000,
	   	  		    params: {
	   	  		    	records:JSON.stringify(arr),ENTITY_ID:ENTITY_ID
	   	  		    },
	                      success: function(response) {
	                    	  Ext.MessageBox.alert("提示","保存成功");
	                          },

	   	  		});
	    		   })
     		
        }
     }
  }
  );
//    	var p = new Ext.data.Record({  
//         ID: '',  
//         ENTITIES_FULLNAME: '',  
//         INVOICE_TITLE: ''
       
//     }); 
	
   	var tbtn222 = new Ext.Button({
   	 	text: '删除',
   	 	handler: function(){
   	 		var records = invoice_title.getSelectionModel().getSelection();
   	 		alert(records);
   	 		if(records.length==0){
   	 				Ext.Msg.alert("提示","请选中需要删除的实体记录");return;
   	 			}
   	 			var arr = [];
   	 			Ext.each(records,function(item){
   	 				obj = {
   	 						id:item.data.ID
   	 						
   	 						
   	 				};
   	 				arr.push(obj);
   	 				
   	 			});
   	 			var array = JSON.stringify(arr);
   	 			Ext.Ajax.request({
   	 						url: '<%=basePath%>entityMaintain/deleteInvoice',
   							params:{
//   	 							records:Ext.JSON.encode(arr)
   								array:array
   									
   							},
   							timeout:5000,
   							success:function(response){
   								 Ext.MessageBox.alert("删除","删除成功");
   								 var grid = Ext.getCmp('invoice_title');
   								 grid.store.reload();
   							},
   							
   						});
   	 	}
   	}
   	);
   	var invoice_unit_cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 2});
// 	var invoice_title = new Ext.grid.EditorGridPanel({
	var invoice_title = new Ext.grid.GridPanel({
		title : '发票抬头维护',
		id : 'invoice_title',
		store : store2,
		 columns: cv,
		region:'east',
		width:'37%',
// 		loadMask : true,
// 		trackMouseOver : false,
// 		viewConfig : {
// 			forceFit : false
// 		},	
// 		columnLines: true,
		plugins:[invoice_unit_cellEditing],
		tbar: [tbtn111,tbtn222,tbtn333],
		autoExpandColumn:3,
		selModel : Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}),
		bbar :new Ext.PagingToolbar({
			pageSize : 12,
			store : store2,
			displayInfo : true,
			emptyMsg : "<span style='color:red'>没有查询到符合的记录</span>"
		})
// 		autoWidth : true,
// 		enableColumnResize : true,
// 		height : 325,
// 		sm : Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}),
// 		renderTo : 'invoice_title'
			
	});
	invoice_title.getStore().reload();
	
	new Ext.Viewport({
		layout : 'border',					
		items : [monitorAnalyze,contractInfo,invoice_title]
	});
	 /**>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>发票抬头维护js结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
});
	




</script>
</html>